package com.woniuxy.service.impl;

import com.woniuxy.service.RbacManagerService;
import com.woniuxy.dao.RbacManagerDao;
import com.woniuxy.entity.RbacManager;

import java.util.List;
import java.util.Objects;

/**
 * @Author: 马宇航
 * @Todo: Manger业务层实现类
 * @DateTime: 22/08/22/0022 10:56
 * @Component: 成都蜗牛学苑
 **/
public class RbacManagerServiceImpl implements RbacManagerService {
    private RbacManagerDao rbacManagerDao;

    public void setRbacManagerDao(RbacManagerDao rbacManagerDao) {
        this.rbacManagerDao = rbacManagerDao;
    }

    @Override
    public RbacManager findOne(int id) {
        System.out.println("这个是一个日志：我记录了id是："+id+"的用户的查询操作！");
        RbacManager one = rbacManagerDao.findOne(id);
        if (Objects.nonNull(one)){
            System.out.println("查询"+id+"用户成功！");
        }else {
            System.out.println("查询"+id+"用户失败！");
        }
        return one;
    }

    @Override
    public List<RbacManager> findAll() {
        List<RbacManager> all = rbacManagerDao.findAll();
        all.forEach(System.out::println);
        return all;
    }

    @Override
    public int addOne(RbacManager rbacManager) {
        return rbacManagerDao.addOne(rbacManager);
    }

    @Override
    public int updateOne(RbacManager rbacManager) {
        return rbacManagerDao.updateOne(rbacManager);
    }

    @Override
    public int deleteOne(int id) {
        return rbacManagerDao.deleteOne(id);
    }
}
